package teach.aistar.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import teach.aistar.model.entity.CarBrands;
import teach.aistar.model.entity.CarDetail;
import teach.aistar.model.entity.CarStyle;
import teach.aistar.model.entity.WebSeckill;
import teach.aistar.service.ICarBandsService;
import teach.aistar.service.ICarDetailService;
import teach.aistar.service.ICarStyleService;
import teach.aistar.service.IWebSeckillService;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("/user")
public class EditSeckillController {
    @Autowired
    private IWebSeckillService iWebSeckillService;

    @Autowired
    private ICarDetailService iCarDetailService;

    @Autowired
    private ICarStyleService iCarStyleService;

    @Autowired
    private ICarBandsService iCarBandsService;

    @GetMapping("/seckills")
    public String seckill(HttpServletRequest request){
        //显示秒杀商品
        List<CarDetail> carDetails=iCarDetailService.selectAll();
        List<WebSeckill> webSeckills=iWebSeckillService.selectWebSeckillAll();
        List<CarStyle> carStyles=iCarStyleService.findAll();
        List<CarBrands> carBrands=iCarBandsService.selectAll();

        request.setAttribute("carDetailsList",carDetails);
        request.setAttribute("webSeckillsList",webSeckills);
        request.setAttribute("carStylesList",carStyles);
        request.setAttribute("carBrandsList",carBrands);


        return "/jsp/backend/page-list-seckills";
    }

    //上架秒杀商品,下拉框显示
    @GetMapping("/addSeckill")
    public String addSeckill(HttpServletRequest request){
        List<CarStyle> carStyles=iCarStyleService.findAll();
        List<CarBrands> carBrands=iCarBandsService.selectAll();

        request.setAttribute("carStyleList",carStyles);
        request.setAttribute("carBrandList",carBrands);

        return "/jsp/backend/page-add-seckill";
    }
    //上架秒杀商品
    @GetMapping("/addSeckill1")
    public String addSeckill1(HttpServletRequest request){
        String carBrands=(String) request.getParameter("carBrands");
        String carstyle=(String) request.getParameter("carstyle");
        String gear=(String) request.getParameter("gear");
        String seat=(String) request.getParameter("seat");
        String num=(String) request.getParameter("num");
        String price=(String) request.getParameter("price");
        String starttime=(String) request.getParameter("starttime");
        String endtime=(String) request.getParameter("endtime");
        String status=(String) request.getParameter("status");

        CarDetail carDetail=new CarDetail();
        WebSeckill webSeckill=new WebSeckill();
        if (carBrands != null){
        }
        return "/jsp/backend/page-list-seckills";
    }

    //编辑秒杀商品信息
    @GetMapping("/editSeckill")
    public String editSeckill(HttpServletRequest request){


        return "/jsp/backend/page-edit-seckill";
    }

    //编辑秒杀商品信息2
    @GetMapping("/editSeckill2")
    public String editSeckill2(HttpServletRequest request){


        return "redirect:/user/seckills";
    }
}
